﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Snowdreamist.Collection;

namespace SNSpirit.Domain.Forum
{
    /// <summary>
    /// Thread
    /// 帖子
    /// </summary>
    public class Thread : LazyDomainEntity
    {
        public Thread(ForumService service)
            : base(new LoadAction<LazyDomainEntity>(o =>
                {
                    service.UpdateCore(o as Thread);
                }))
        {
            if (service == null)
                throw new ArgumentNullException("service");
            this.Service = service;
        }

        public ForumService Service { get; private set; }

        #region Title

        private object _Title;

        /// <summary>
        /// Title
        /// </summary>
        public object Title
        {
            get { return this._Title; }
            set
            {
                if (this._Title != value)
                {
                    this._Title = value;
                    this.OnPropertyChanged("Title");
                }
            }
        }

        #endregion Title

        /// <summary>
        /// Posts
        /// </summary>
        public ConcurrentCollection<Post> Posts { get; private set; }

        /// <summary>
        /// Update this thread
        /// </summary>
        public virtual void Update()
        {
            this.Load();
        }

        public virtual void UpdateAsync()
        {
            this.LoadAsync();
        }

        /// <summary>
        /// To do
        /// </summary>
        public bool IsSubscribed { get; set; }

        /// <summary>
        /// Subscribe this thread (get notification)
        /// </summary>
        public virtual void Subscribe()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Unsubscribe this thread
        /// </summary>
        public virtual void Unsubscribe()
        {
            throw new NotImplementedException();
        }
    }
}